using System.Collections.Generic;
using Dapper;

namespace Lib.Db
{
    public class UserRepository
    {
        private readonly IDbProvider _dbProvier;

        public UserRepository(IDbProvider dbProvider) {
            _dbProvier = dbProvider;
        }

        public IEnumerable<UserEntity> ListUsers(int limit){
            return  _dbProvier.Get().Query<UserEntity>($"SELECT TOP {limit} * FROM dbo.T_MGT_User ORDER BY Id DESC");
        }

        public UserEntity GetEntity(int id) {
            return _dbProvier.Get().QueryFirstOrDefault<UserEntity>($"SELECT * FROM dbo.T_MGT_User WHERE Id = {id}");
        }
    }
}